package Dome01;

import java.util.ArrayList;
import java.util.Scanner;

public class ChengXinShangDian {
	public static void main(String[] args) {
		System.out.print("********成信大超市********");
		Goods [] a = new Goods [3];
		a[0] = new Goods();
		a[0].id = 1001;
		a[0].name = "泡面";
		a[0].price = 4.0;
		a[0].number = 5;
		a[0].money = 2.5;
		
		a[1] = new Goods();
		a[1].id = 1002;
		a[1].name = "奶茶";
		a[1].price = 3.0;
		a[1].number = 10;
		a[1].money = 4;
		
		a[2] = new Goods();
		a[2].id = 1003;
		a[2].name = "面包";
		a[2].price = 3.5;
		a[2].number = 20;
		a[2].money = 3;
		
		ArrayList<Goods> list = new ArrayList<Goods>();
		list.add(a[0]);list.add(a[1]);list.add(a[2]);
		while(true){
			System.out.println("\n1.货物清单\n2.添加新货物\n3.删除获取\n4.修改货物\n5.退出\n选择:");
			int week = new Scanner(System.in).nextInt();
		switch(week){
		case 1:
			qingDan(list);
			break;
		case 2:
			tianJia(list);
			break;
		case 3:
			shanchu(list);
			break;
		case 4:
			xiuGai(list);
			break;
		case 5:
			tuiChu();
			return;
			default:
			System.out.print("输入错误请重新输入");
		}
		}
	}

	private static void shanchu(ArrayList<Goods> list) {
		System.out.println("删除商品名字");
		String name ;
		name = new Scanner(System.in).next();
		int week = 0;
		for(int i=0;i<list.size();i++){
		if(list.get(i).name.equals(name))
			week=i;}
		list.remove(week);
		
	}

	public static void tuiChu() {
		// TODO Auto-generated method stub
		
	}

	public static void xiuGai(ArrayList<Goods> list) {
		Goods cun = new Goods();
		System.out.println("输入名字");
		String name ;
		name = new Scanner(System.in).next();
		int week = 0;
		for(int i=0;i<list.size();i++){
		if(list.get(i).name.equals(name))
			week=i;}
		list.get(week).money=new Scanner(System.in).nextInt();
		
	}

	public static void tianJia(ArrayList<Goods> list) {
		Goods a = new Goods();
		System.out.println("id:");
		a.id = new Scanner(System.in).nextInt();
		System.out.println("name:");
		a.name = new Scanner(System.in).next();
		System.out.println("price:");
		a.price = new Scanner(System.in).nextDouble();
		System.out.println("number:");
		a.number = new Scanner(System.in).nextDouble();
		System.out.println("money:");
		a.money = new Scanner(System.in).nextInt();
		list.add(a);
		
	}

	public static void qingDan(ArrayList<Goods> list) {
		for(int i=0;i<list.size();i++){
			System.out.print("id:"+list.get(i).id+" ");
			System.out.print("名字"+list.get(i).name+" ");
			System.out.print("大小"+list.get(i).price+" ");
			System.out.print("价格"+list.get(i).money+" ");
			System.out.print("数量"+list.get(i).number+" ");
			System.out.println("");
		}
		
	}
}
	